home *** CD-ROM | disk | FTP | other *** search
/ stazsoftware.com / www.stazsoftware.com.tar / www.stazsoftware.com / futurebasic / sample-code / RezLib.sit / RezLib / Put in Headers folder / Tlbx RezLib.incl next >
Text File  |  2003-05-14  |  5KB  |  107 lines

  1.  
  2. // Robert P.   14 May 2003
  3.  
  4. /*
  5. "RezLib is an attempt to unify display color depth and resolution
  6. switching, gamma fading, and vertical retrace synchronization
  7. under a common API for both MacOS 8/9 and MacOS X. It is provided
  8. free of charge as a shared library for use under Carbon."
  9.  
  10. RezLib is written by Ian Ollman
  11. See www.versiontracker.com or do a Google search, to find the latest version of RezLib
  12. */
  13.  
  14. #if CarbonLib == 0
  15. compile shutdown "RezLib requires Carbon"
  16. #endif
  17.  
  18. begin record RLInfo
  19. dim as UInt32   resolutionID   //unique identifier for this rez/color depth combo
  20. dim as UInt32   refreshRate   //16.16 fixed point in Hz      
  21. dim as UInt32   height     //height in pixels        
  22. dim as UInt32   width     //width in pixels        
  23. dim as UInt32   colorDepths   //colordepths allowed at this rez in bits -- i.e. if 8 and 32 bit color depths were alowed, the value would be 8 | 32 = 40 (=0x00000028). GetCurrentScreenSetting returns only the color depth currently in use.
  24. dim as UInt16   flags     //See RLInfo flags below      
  25. dim as Boolean  isSafe     //True if the resolution is known to function correctly. If false, it may still work, but you need to test.
  26. dim as char     rlInfoType    //Reserved for later use. Pass 0 here.   
  27. dim as Str31    name //Name of this setting as a pascal string 
  28. end record
  29.  
  30. begin record RLDrawInfo
  31. dim as Ptr     baseAddr
  32. dim as UInt32  rowBytes
  33. dim as UInt32  bitsPerPixel
  34. dim as Rect    bounds
  35. dim as UInt32  reserved  //Unused. Pass 0 here
  36. end record
  37.  
  38. /* RLInfo flags  */
  39. _rlDisplayModeIsStretched = 1 /*Set if the resolution is distorted. (e.g. 1024x768 stretched to fit a 1200x768 display) */
  40. _rlDisplayModeRequresPanning = 2 /*Set if the entire resolution cannot fit on the screen at the same time -- panning is required. */
  41. _rlDisplayModeInterlaced = 4
  42. _rlDisplayModeMatchingBits = _rlDisplayModeIsStretched or _rlDisplayModeRequresPanning or _rlDisplayModeInterlaced
  43.  
  44. // ScreenRef is a opaque pointer to a class that handles one display.
  45. #define ScreenRef    as long
  46. #define RetraceToken as long
  47.  
  48. begin record RLGammaTable
  49. dim as single red[255], green[255], blue[255]
  50. end record
  51.  
  52. library "RezLib"
  53. toolbox fn NewScreenRef( const Rect *where, OSStatus *error ) = ScreenRef
  54. toolbox DisposeScreenRef( ScreenRef display )
  55.  
  56. toolbox fn GetDisplayList( unsigned long *listEntryCount ) = Ptr // to Rect
  57. toolbox DisposeDisplayList( Rect *list )
  58.  
  59.  
  60. // Returns the current resolution and color depth being used by the display.
  61. toolbox fn GetCurrentSetting( ScreenRef screen, RLInfo *info ) = OSStatus
  62. // Returns all of the color depths available at the current resolution. If 32 and 8 bit color are available,
  63. // you wll get back 32 | 8 = 40  (0x28) as a result
  64. toolbox fn GetColorDepthsAtThisResolution( ScreenRef screen ) = UInt32
  65.  
  66. toolbox fn GetResolutionList( ScreenRef screen, unsigned long *listEntryCount ) = Ptr // to RLInfo
  67. toolbox DisposeResolutionList( ScreenRef screen, RLInfo *list )
  68.  
  69. toolbox fn SetColorDepth( ScreenRef screen, UInt32 colorDepth ) = OSStatus
  70. toolbox fn SetResolution( ScreenRef screen, UInt32 resolutionID ) = OSStatus
  71. toolbox fn SetResolutionAndColorDepth( ScreenRef screen, UInt32 resolutionID, UInt32 colorDepth ) = OSStatus
  72. toolbox fn AskIfNewResolutionWorks( ScreenRef screen ) = OSStatus // returns rlRezNotFound if the new rez doesn't work. noErr otherwise
  73.  
  74. toolbox fn GetCurrentScreenDrawingInfo( ScreenRef screen, RLDrawInfo *info ) = OSStatus
  75.  
  76. toolbox fn GetGamma( ScreenRef screen, RLGammaTable *gamma ) = OSStatus
  77. toolbox fn SetGamma( ScreenRef screen, const RLGammaTable *gamma ) = OSStatus
  78.  
  79. // The 'seconds' parameter here should be a float (i.e. FB single), but we define it as 
  80. // double to overcome a limitation of FB, which cannot pass singles to a toolbox routine.
  81. toolbox fn FadeToGamma( ScreenRef screen, const RLGammaTable *gamma, double seconds ) = OSStatus
  82. toolbox fn FadeToColor( ScreenRef screen, const RGBColor *color, double seconds ) = OSStatus
  83. toolbox fn FadeToGammaMultiple( ScreenRef *screen, unsigned int count, const RLGammaTable *gammaList, double seconds ) = OSStatus
  84. toolbox fn FadeToColorMultiple( ScreenRef *screen, unsigned int count, const RGBColor *color, double seconds ) = OSStatus
  85.  
  86.  
  87. toolbox fn AcquireDesktop( ScreenRef screen, WindowRef *window, const RGBColor *background ) = OSStatus
  88. toolbox fn ReleaseDesktop( ScreenRef screen ) = OSStatus
  89.  
  90. toolbox fn SaveIconPositions( ScreenRef screen, Handle *desktopInfo ) = OSStatus
  91. toolbox fn RestoreIconPositions( ScreenRef screen, Handle desktopInfo ) = OSStatus
  92.  
  93. toolbox fn WaitForVerticalRetrace( ScreenRef screen ) = OSStatus
  94. toolbox fn InstallVerticalRetraceProcedure( ScreenRef screen, proc callback, long userData ) = RetraceToken
  95. toolbox DisposeVerticalRetraceProcedure( RetraceToken token )
  96. toolbox fn EmulateVerticalRetraceProcedure( ScreenRef screen, UInt32 refreshRate, proc callback, long userData ) = RetraceToken
  97.  
  98. toolbox fn GetRezLibVersion( long *version ) = OSStatus // parameter is really a NumVersion
  99. library
  100.  
  101. /*
  102. _rlColorDepthNotAvailable = 6 // color depth requested is not available 
  103. _rlRezNotFound = 7 // resolution requested was not found
  104. */
  105.  
  106.  
  107.